<template>
     <div class="manage1">
        <el-form :inline="true" class="manage1_from1">
         <el-form-item label=""></el-form-item>
           <el-form-item label="会员名称：">
               <el-input v-model="param.nickname" placeholder="会员名称" clearable class="manage1_from1_input1" />
           </el-form-item>


           <el-form-item label="会员手机号：">
               <el-input v-model="param.mobile" placeholder="会员手机号" clearable class="manage1_from1_input1" />
           </el-form-item>

<!-- 
           <el-form-item label="支付金额：">
               <el-input v-model="param.totalAmount" placeholder="支付金额" clearable class="manage1_from1_input1" />
           </el-form-item> -->


           <el-form-item label="时间：">
               <el-date-picker v-model="param.startTime" type="date" class="manage1_from1_time1" placeholder="开始时间"
                               format="YYYY-MM-DD" value-format="YYYY-MM-DD" clearable /> &nbsp; 至 &nbsp;
               <el-date-picker v-model="param.endTime" type="date" class="manage1_from1_time1" placeholder="结束时间"
                               format="YYYY-MM-DD" value-format="YYYY-MM-DD" clearable />
           </el-form-item> <br />


           <el-form-item label="支付方式：">
               <el-select v-model="param.payName" @change="schoolCge" placeholder="微信,支付宝" clearable
                          class="manage1_from1_select1">
                    <el-option key="1" label="微信支付" value="微信支付" />
                    <el-option key="2" label="支付宝支付" value="支付宝支付" />
                    <el-option key="2" label="苹果支付" value="苹果支付" />
               </el-select>
           </el-form-item>


            <el-form-item>
                <el-button type="primary" class="manage1_from1_button1" @click="getList(1)">搜索</el-button>
                <el-button @click="rewrite" text type="primary">
                    <el-icon :size="16">
                        <refresh />
                    </el-icon> &nbsp;重置筛选条件
                </el-button>
                <el-button @click="exportList" type="primary" class="w115" >导出</el-button>
            </el-form-item>
        </el-form>
    </div>
    <div class="list1" v-if="param.tablestatus ==1" v-loading="loading">
        <el-table ref="selectTable" :data="list1">
                            <el-table-column prop="orderLogId" min-width="120" label="id"></el-table-column>

                            <el-table-column prop="nickname" min-width="120" label="会员名称"></el-table-column>

                            <el-table-column prop="mobile" min-width="120" label="手机号"></el-table-column>

                            <el-table-column prop="totalAmount" min-width="120" label="支付金额"></el-table-column>

                            <el-table-column prop="payName" min-width="80" label="支付渠道" >
                                <!-- <template #default="scope">
                                    {{payName[scope.row.payName]}}
                                </template> -->
                            </el-table-column>

                            <el-table-column prop="payTime" min-width="120" label="支付时间"></el-table-column>

            <el-table-column fixed="right" label="操作" min-width="200">
                <template #default="scope">
                    <div class="list1_operate1">
                    </div>
                </template>
            </el-table-column>
        </el-table>


        <div class="list1_page1">
            <p class="list1_page1_title1">共 {{ total }} 条</p>
            <el-pagination v-model:currentPage="param.pageNumber" @size-change="handleSizeChange"
                           @current-change="handleCurrentChange" :page-sizes="[10, 15, 20, 25]" :page-size="param.pageSize"
                           layout=" sizes, prev , jumper , next" :total="total">
            </el-pagination>
        </div>
    </div>


</template>
<script>
    
export default {
    data() {
        return {
            param:{},
            list1:[],

            param: {
                pageNumber: 1,
                pageSize: 10,
                tablestatus: 1,
            },            
            loading: false,
            total: 0,
            payName:{1:'待付款',2:'已付款'},
        }
    },

    created() {
    this.getList()
    },

    mounted() {
    },

    components: {
    },

    methods: {
        rewrite() {
            let that = this;
            let obj = {
                pageNumber: that.param.pageNumber,
                pageSize: that.param.pageSize,
                tablestatus: that.param.tablestatus
            }
            that.param = obj;
        },
        handleSizeChange(val) {
            console.log(`每页 ${val} 条`);
            this.param.pageSize = val;
            this.getList();
        },
        handleCurrentChange(val) {
            console.log(`当前页: ${val}`);
            this.param.pageNumber = val;
            this.getList();
        },

        // 导出
        exportList(){
            let that = this;

            that.$api.exportFinanceListTemplate(this.param).then(res=>{
                console.log(res,'res--------')
                if (res ) {
                    const blob = new Blob([res], { type: 'application/octet-stream' }) // 构造一个blob对象来处理数据
                    if (window.navigator.msSaveOrOpenBlob) { //兼容IE10
                        navigator.msSaveBlob(blob, '财务列表')
                    } else {
                        const href = URL.createObjectURL(blob) //创建新的URL表示指定的blob对象
                        const a = document.createElement('a') //创建a标签
                        a.style.display = 'none'
                        a.href = href // 指定下载链接
                        a.download = '财务列表.xls' //指定下载文件名
                        a.click() //触发下载
                        URL.revokeObjectURL(a.href) //释放URL对象
                    }
                }
            })
        },


     getList(pageNumber) {
            this.loading = true;
            let res;
            if (pageNumber) {
              this.param.pageNumber = pageNumber;
            }
            this.$api.financelist(this.param).then(res => {
            console.log('res====', res)
            if (res) {
                let url = 'list'+this.param.tablestatus
                this[url] = res.records
                this.total = res.total;
            }
            })
            this.loading = false;
        },


    }

}


</script>
<style lang="scss" scoped>
.manage1{
    padding: 10px 20px 10px;
    background-color: #fff;
    text-align: left;
    .manage1_from1{
        background: #F2F3F5;
        padding: 24px 16px 4px;
        text-align: left;
        .manage1_from1_input1{width: 250px}
        .manage1_from1_input2{width: 110px;margin-right: 10px;}
        .manage1_from1_input3{width: 110px;margin-left: 10px;}
        .manage1_from1_select1{width: 250px}
        .manage1_from1_time1{width: 110px}
        .manage1_from1_button1{width: 115px;}
    }

}
.list1{
    background-color: #fff;
    .list1_head1{
        width: 40px;height: 40px;
        border-radius: 50%;
    }
    .list1_operate1{
        width: 100%;
        display: flex;
        justify-content: center;
        .list1_operate1_line1{margin: auto 10px;}
    }
    .list1_page1{
        height: 70px;
        padding: 20px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        .list1_page1_title1{
            font-size: 10px;color: #A4A4A4;
        }
    }
}

</style>